from django.conf import settings
from django.db.models import CharField, FloatField,IntegerField

# 继承框架封装的 模型类 CoreModel

from apps.vadmin.op_drf.models import BaseModel


class StockModel(BaseModel):
    '''
        "symbol_single_stock": "最大市值股票名称",
               "mv_single_stock": "最大个股市值",
               "ratio_single_stock": "最大个股市值占比",
               # "mv_share_hold": "个股持仓比例风险",
               "symbol_share_hold": "最大股本占比股票名称",
               "mv_share_hold": "最大股本占比股票市值",
               "ratio_share_hold": "最大股本占比股票占股本比例",
               "industry": "最大单一行业权重行业名称",
               "mv_industry": "最大单一行业市值",
               "ratio_industry": "最大单一行业权重比率",
               "mv_sum": "总市值",
               "mv_sze": "深市总市值",
               "mv_sse": "沪市总市值",
               "mv_cyb": "深市总市值",
               "mv_kcb": "沪市总市值",
               "ratio_mv_sze": "深市市值占比",
               "ratio_mv_sse": "沪市市值占比",
               "ratio_mv_cyb": "深市市值占比",
               "ratio_mv_kcb": "沪市市值占比",
               "cnt_stock_hold": "当日持股数量",
               "cnt_stock_hold_prev": "前日持股数量",
               "cnt_order": "当日委托总数",
               "cnt_cncl": "当日撤单总数",
               "ratio_cncl": "当日撤单率",
               "tovr": "当日交易额",
               "ratio_tovr": "当日换手率",
               "ratio_cncl_tovr": "当日撤单率(金额)",
               "ratio_cross_cncl": "对价单撤单率(次数)",
               "ratio_limit_cncl": "限价单撤单率(次数)",
               "ratio_cross_div_limit": "对价单/限价单"
    '''

    name = CharField(max_length=128, verbose_name='项目名称')
    symbol_single_stock = FloatField(null=True, blank=True, verbose_name='最大市值股票名称')
    mv_single_stock = FloatField(null=True, blank=True, verbose_name='最大个股市值')
    ratio_single_stock = FloatField(null=True, blank=True, verbose_name='最大个股市值占比')
    symbol_share_hold = FloatField(null=True, blank=True, verbose_name='最大股本占比股票名称')
    mv_share_hold = FloatField(null=True, blank=True, verbose_name='最大股本占比股票市值')
    ratio_share_hold = FloatField(null=True, blank=True, verbose_name='最大股本占比股票占股本比例')
    industry = FloatField(null=True, blank=True, verbose_name='最大单一行业权重行业名称')
    mv_industry = FloatField(null=True, blank=True, verbose_name='最大单一行业市值')
    ratio_industry = FloatField(null=True, blank=True, verbose_name='最大单一行业权重比率')
    mv_sum = FloatField(null=True, blank=True, verbose_name='总市值')
    mv_sze = FloatField(null=True, blank=True, verbose_name='深市总市值')
    mv_sse = FloatField(null=True, blank=True, verbose_name='沪市总市值')
    mv_cyb = FloatField(null=True, blank=True, verbose_name='深市总市值')
    mv_kcb = FloatField(null=True, blank=True, verbose_name='沪市总市值')
    ratio_mv_sze = FloatField(null=True, blank=True, verbose_name='深市市值占比')
    ratio_mv_sse = FloatField(null=True, blank=True, verbose_name='沪市市值占比')
    ratio_mv_cyb = FloatField(null=True, blank=True, verbose_name='深市市值占比')
    ratio_mv_kcb = FloatField(null=True, blank=True, verbose_name='沪市市值占比')
    cnt_stock_hold = FloatField(null=True, blank=True, verbose_name='当日持股数量')
    cnt_stock_hold_prev = FloatField(null=True, blank=True, verbose_name='前日持股数量')
    cnt_order = FloatField(null=True, blank=True, verbose_name='当日委托总数')
    cnt_cncl = FloatField(null=True, blank=True, verbose_name='当日撤单总数')
    ratio_cncl = FloatField(null=True, blank=True, verbose_name='当日撤单率')
    tovr = FloatField(null=True, blank=True, verbose_name='当日交易额')
    ratio_tovr = FloatField(null=True, blank=True, verbose_name='当日换手率')
    ratio_cncl_tovr = FloatField(null=True, blank=True, verbose_name='当日撤单率(金额)')
    ratio_cross_cncl = FloatField(null=True, blank=True, verbose_name='对价单撤单率(次数)')
    ratio_limit_cncl = FloatField(null=True, blank=True, verbose_name='限价单撤单率(次数)')
    ratio_cross_div_limit = FloatField(null=True, blank=True, verbose_name='对价单/限价单')
    state = CharField( max_length=1,default="0", verbose_name="状态")

    # 在关联用户时，建议使用 to=settings.AUTH_USER_MODEL 进行关联
    class Meta:
        verbose_name = '模板'
        verbose_name_plural = verbose_name

    def __str__(self):
        return f"{self.name} 项目"